import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { join } from "path"
const resolve = (dir) => join(__dirname, dir)

// https://vitejs.dev/config/
export default defineConfig((options) => {
  const env = loadEnv(options.mode, process.cwd())
  const { VITE_PORT, VITE_BASE_URL } = env
  // console.log(options, env)
  return {
    base: VITE_BASE_URL,
    plugins: [react()],
    server: {
        port: VITE_PORT,
        hmr: true
    },
    resolve: {
      alias: {
        "@": resolve("src") // 设置别名 https://blog.csdn.net/qq_40254596/article/details/141288074
      }
    }
  }
})

// TODO：热更新没有反应
